<?php
namespace ImiApp\Module\Api\Controller;

use Imi\Aop\Annotation\Inject;
use Imi\Server\Route\Annotation\Action;
use Imi\Controller\SingletonHttpController;
use Imi\Server\Route\Annotation\Controller;

/**
 * @Controller("/api/")
 */
class ApiController extends SingletonHttpController
{
    /**
     * @Inject("StatisticsService")
     *
     * @var \ImiApp\Service\StatisticsService
     */
    protected $statisticsService;

    /**
     * @Inject("AreaDataService")
     *
     * @var \ImiApp\Service\AreaDataService
     */
    protected $areaDataService;

    /**
     * @Action
     *
     * @return void
     */
    public function statistics()
    {
        return [
            'data'  =>  $this->statisticsService->getLastModify(),
        ];
    }

    /**
     * @Action
     *
     * @param int $city
     * @return void
     */
    public function areas($city = 1)
    {
        return $this->areaDataService->selectLastModify(1 == $city);
    }

}
